﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using EGym.Data;
using Trirand.Web.Mvc;
using TextAlign=System.Web.UI.WebControls.TextAlign;

namespace EGym.BL.Forms
{
    public class AlunoForm : ListForm
    {
        #region Construtores
        public AlunoForm()
        {
            Lista = new List<Aluno>();
            Aluno = new Aluno();
            InitializateGrids();
        }
        #endregion

        #region Propriedades
        public IEnumerable<Aluno> Lista { get; set; }
        public Aluno Aluno { get; set; }
        public JQGrid GridMain { get; set; }
        #endregion

        #region Metodos
        #region Privados
        private void InitializateGrids()
        {
            InitializateGridMain();
        }

        private void InitializateGridMain()
        {
            GridMain = new JQGrid
                           {
                               Columns = new List<JQGridColumn>()
                                             {
                                                 new JQGridColumn
                                                     {
                                                         DataField = "AlunoId",
                                                         // always set PrimaryKey for Add,Edit,Delete operations
                                                         // if not set, the first column will be assumed as primary key
                                                         PrimaryKey = true,
                                                         Editable = false,
                                                         Visible = false,
                                                     },
                                                 new JQGridColumn
                                                     {
                                                         DataField = "AfiliadoId",
                                                         // always set PrimaryKey for Add,Edit,Delete operations
                                                         // if not set, the first column will be assumed as primary key
                                                         PrimaryKey = true,
                                                         Editable = false,
                                                         Visible = false,
                                                     },
                                                 new JQGridColumn
                                                     {
                                                         DataField = "Nome",
                                                         Editable = true
                                                     },
                                                 new JQGridColumn
                                                     {
                                                         DataField = "DataCadastro",
                                                         Editable = true,
                                                         Width = 100,
                                                         DataFormatString = "{0:dd/MM/yyyy}"
                                                     },
                                                 new JQGridColumn
                                                     {
                                                         DataField = "DataNascimento",
                                                         Editable = true,
                                                         Width = 100,
                                                         DataFormatString = "{0:dd/MM/yyyy}"
                                                     },
                                                 new JQGridColumn
                                                     {
                                                         DataField = "Email",
                                                         Editable = true,
                                                         Width = 300,
                                                         HtmlEncode = true,
                                                         HtmlEncodeFormatString = false,
                                                         DataFormatString = "<a href=\"mailto:{0}\">{0}</a>"
                                                     },
                                             },
                               Width = Unit.Pixel(690),
                               ColumnReordering = true,
                               ID = "grdAlunoMain",
                               Height = Unit.Pixel(380)
                           };
        }

        #endregion
        #endregion

    }
}
